package com.project.pet.utils;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ConvertUtil {

    public Map<String,Object> beanToMap(Object obj){
        Map<String,Object> map = JSON.parseObject(JSON.toJSONString(obj), Map.class);
        return map;
    }


    public List<Map<String,Object>> beanToMap(List<Object> list){
        List<Map<String, Object>> res = new ArrayList<>();
        for (Object o : list) {
            Map<String, Object> map = beanToMap(o);
            res.add(map);
        }
        return res;
    }
}
